package com.app.micaihu.view.army.adapter.messageprovider

import android.widget.ImageView
import com.app.micaihu.R
import com.app.micaihu.view.army.adapter.ArmyMessageListAdapter
import com.app.micaihu.view.bean.ArmyMessage
import com.app.micaihu.view.user.userinfo.activity.MyHomepageDynamicActivity
import com.app.micaihu.view.utils.loadCircleImage
import com.app.micaihu.view.utils.loadImage
import com.blankj.utilcode.util.ActivityUtils
import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * 军团消息  管理员消息
 */
class MessageManageItemProvider : BaseItemProvider<ArmyMessage>() {

    override val itemViewType: Int
        get() = ArmyMessageListAdapter.itemManage

    override val layoutId: Int
        get() = R.layout.army_message_list_manage_item

    //列表 状态0等待通过，1已通过，2拒绝，3退出
    override fun convert(helper: BaseViewHolder, item: ArmyMessage) {
        helper.setText(R.id.tvTime, item.datetime)
        helper.getView<ImageView>(R.id.ivSysIcon).loadCircleImage(R.mipmap.icon)
        helper.setText(R.id.tvDesc, item.msg)
        val ivHeadPic = helper.getView<ImageView>(R.id.ivHeadPic)
        ivHeadPic.loadCircleImage(item.avatar, R.drawable.user_head_def)
        helper.getView<ImageView>(R.id.ivRankIcon).loadImage(item.rankIcon)
        helper.setText(R.id.tvRankName, item.rankName)
        helper.setText(R.id.tvNickName, item.nickname)

        when (item.status) {
            0 -> {
                helper.setVisible(R.id.tvReject, true)
                helper.setVisible(R.id.tvAgree, true)
                helper.setGone(R.id.tvState, true)
            }
            1 -> {
                helper.setGone(R.id.tvReject, true)
                helper.setGone(R.id.tvAgree, true)
                helper.setVisible(R.id.tvState, true)
                helper.setText(R.id.tvState, "已通过")
            }
            2 -> {
                helper.setGone(R.id.tvReject, true)
                helper.setGone(R.id.tvAgree, true)
                helper.setVisible(R.id.tvState, true)
                helper.setText(R.id.tvState, "已拒绝")
            }
        }

        ivHeadPic.setOnClickListener {
            MyHomepageDynamicActivity.goToUserHomePage(ActivityUtils.getTopActivity(), item.from_uid)
        }
    }

}